﻿using System;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Controls;
using System.Globalization;

namespace SBPweb.Communication.Client.Presentation.Silverlight.Utilities
{

    public class ImageSourceConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (targetType == typeof(System.Windows.Media.ImageSource))
            {
                if (parameter == null)
                {
                    parameter = "{0}";
                }
                return new BitmapImage(new Uri(string.Format(parameter.ToString(), value.ToString()), UriKind.Relative));
            }
            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

    }

}
